package com.his.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.his.admin.service.RoleMenuService;
import com.his.dao.domain.dto.ListDto;
import com.his.dao.domain.dto.SelectRoleMenuDto;
import com.his.dao.domain.entity.Hospital;
import com.his.dao.domain.entity.RoleMenu;
import com.his.dao.domain.vo.ListVo;
import com.his.dao.domain.vo.SelectAllVo;
import com.his.dao.mapper.RoleMenuMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.his.util.result.RestResult;
import com.his.util.result.RestResultBuilder;
import com.his.util.util.MapUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fall
 * @since 2022-11-28
 */
@Service
@AllArgsConstructor
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {
    private RoleMenuMapper roleMenuMapper;

    @Override
    public RestResult all(SelectRoleMenuDto selectRoleMenuDto) {
        return new RestResultBuilder().success(SelectAllVo
                .builder()
                .list(roleMenuMapper.selectAll(
                        selectRoleMenuDto.getRoleId(),
                        selectRoleMenuDto.getName(),
                        selectRoleMenuDto.getPage() * selectRoleMenuDto.getPageSize(),
                        selectRoleMenuDto.getPageSize()))
                .total(roleMenuMapper.selectAllCount(
                        selectRoleMenuDto.getRoleId(),
                        selectRoleMenuDto.getName()))
                .build());
    }
}
